<input hidden="hidden" id="navValue" value="查询业绩">


<link rel="stylesheet" type="text/css" media="all" href="/static/assets/css/daterangepicker-bs3.css" />

<!--<script type="text/javascript" src="/static/assets/js/jquery-1.8.3.min.js"></script>-->
<!--<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>-->
<script type="text/javascript" src="/static/assets/js/moment.js"></script>
<script type="text/javascript" src="/static/assets/js/daterangepicker.js"></script>


<div class="page-content">
    <div class="page-header">
        <h1>
            业绩记录
            <small>
                <i class="ace-icon fa fa-angle-double-right"></i>
                查询业绩
            </small>
        </h1>
    </div><!-- /.page-header -->

    <div class="row">
        <from class="form-horizontal user-data" role="form">
            <div class="form-group">
                <div class="col-md-5 no-margin-right no-padding-right">
                    <label class="col-sm-4 control-label no-padding-right" for="form-field-1"> 股东电话: </label>
                    <input type="text" name="phone" placeholder="电话号码" class="col-sm-6" value="{$phone}">
                </div>

                <div class="col-md-3">
                    <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> <input name="is_date" id="is_date" {if $is_date}checked="checked"{/if}  type="checkbox"> </label>
                    <div class="input-prepend input-group">
                        <span class="add-on input-group-addon"><i class="glyphicon glyphicon-calendar fa fa-calendar"></i></span>
                        <input class="date" type="date" name="search_date" id="search_date" value="{:input('get.search_date')}">
                    </div>
                </div>

                <button type="submit" id="searchBtn" style="margin-left: 30px;" class="dt-button buttons-collection buttons-colvis btn btn-white btn-primary btn-bold" tabindex="0" aria-controls="dynamic-table" data-original-title="" title="查询"><span><i class="fa fa-search bigger-110 blue"></i></span></button>
            </div>
        </from>

    </div><!-- /.row -->

    {if !empty($list)}
    <div class="row">
        <div class="col-xs-12">
            <table id="simple-table" class="table  table-bordered table-hover">
                <thead>
                <tr>
                    <th class="center">
                        <label class="pos-rel">
                            <input type="checkbox" class="ace">
                            <span class="lbl"></span>
                        </label>
                    </th>
                    <th class="detail-col center">ID</th>
                    <th class="center">股东名称</th>
                    <th class="center">完成业绩(元)</th>
                    <th class="center">统计时间</th>
                    <th class="center">推荐总业绩</th>
                    <th class="center">详情</th>
                </tr>
                </thead>

                <tbody>
                {foreach $list as $val}
                <tr  class="center">
                    <td>
                        <label class="pos-rel">
                            <input type="checkbox" class="ace">
                            <span class="lbl"></span>
                        </label>
                    </td>
                    <td>{$val['id']}</td>
                    <td>{$val->joinShar->User->nickname}</td>
                    <td>{$val->total}</td>
                    <td class="dateval">{$val->date}</td>
                    <td>{$val['total']}</td>
                    <td><button mark="{$val->sid}" class="btn btn-xs btn-success pull-centers showBtn">查看</button></td>
                </tr>
                {/foreach}
                </tbody>
            </table>
           {$page_html['html']}
        </div><!-- /.span -->
    </div><!-- /.row -->
    {else/}
    <div class="row" style="font-size: 14px;margin-top: 50px;"><center> {$message}</center></div>
    {/if}


</div>

<script>
    $(function () {
        $("#searchBtn").click(function () {
            var reg = /^1[3578]\d{9}$/;
            var phone = $('input[name="phone"]').val();
            var is_date = $("#is_date").is(':checked');
            var date = $("#search_date").val();
            var text_href = '';

            if(reg.test(phone)){
                text_href += "phone="+phone;
            }
            if(is_date){
                if(!text_href){
                    text_href += "date="+date;
                }else{
                    text_href += "&date="+date;
                }
            }
            if(text_href){
                text_href = "?"+text_href;
            }

            location.href=location.href.split('?')[0]+text_href;
        });

        $(".showBtn").click(function () {
            var id = $(this).attr('mark');
            var date = $(this).parents('tr').find(".dateval").text().split(' ')[0];
            var url = "{:url('performance/detail')}";
            url = url + '?sid='+id+"&date="+date;

            layer.open({
                type: 2,
                title: false,
                shade: [0],
                area: ['1200px', '600px'],
                offset: 'auto', //右下角弹出
                shift: 2,
                content:url

            });
        });
    })


</script>
<script type="text/javascript">
    $(document).ready(function() {
        $('#search_date').daterangepicker({ singleDatePicker: true }, function(start, end, label) {
            console.log(start.toISOString(), end.toISOString(), label);
        });
    });
</script>